package com.threeti.mecool.web.controller;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**
 * 临时用
 * @author Yuqi Chou 
 * @version May 22, 2012  10:44:47 AM
 */
public class ParameterizableModelMapViewController extends AbstractController {
	
	private String viewName;


	/**
	 * Set the name of the view to delegate to.
	 */
	public void setViewName(String viewName) {
		this.viewName = viewName;
	}

	/**
	 * Return the name of the view to delegate to.
	 */
	public String getViewName() {
		return this.viewName;
	}
 
	/**
	 * Return a ModelAndView object with the specified view name.
	 * @see #getViewName()
	 */
	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Map<String,Object> paramMap=new HashMap<String, Object>();
		Enumeration<String> names = request.getParameterNames();
		while(names.hasMoreElements()){
			String parameterName=names.nextElement();
			paramMap.put(parameterName, request.getParameter(parameterName));
		}
		return new ModelAndView(viewName,paramMap);
	}

}
